/*
 *  GERenderManager.h
 *  GETestRender
 *
 *  Created by Quoc Dung Chu on 19/07/11.
 *  Copyright 2011 Paris 6. All rights reserved.
 *
 */

#ifndef GE_RENDER_MANAGER_H
#define GE_RENDER_MANAGER_H



#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#include "GEPoint3d.h"
#include "GELine3d.h"


namespace game_engine
{
	namespace device
	{
		using namespace game_engine::vect_math;
		
		typedef GEPoint3d<GLfloat>	point3f;
		typedef GELine3d<GLfloat>	line3f;

		class GEColor  
		{
		public:
			GEColor():R(0),G(0),B(0),A(0){}
			GEColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a):R(r),G(g),B(b),A(a){}
	
			GLubyte R;
			GLubyte G;
			GLubyte B;
			GLubyte A;
		};
		
		inline void draw (point3f point , GEColor color)
		{
			const GLubyte colors[] = {
				color.R, color.G, color.B, color.A
			};
			
			const GLfloat vertices[] = { 
				point.X, point.Y, point.Z
			}; 
			
			glVertexPointer(3, GL_FLOAT, 0, vertices);
			glEnableClientState(GL_VERTEX_ARRAY);
			glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
			glEnableClientState(GL_COLOR_ARRAY);
			glDrawArrays(GL_POINTS, 0, 1);
		}
		
		
		inline void draw (line3f line , GEColor color)
		{
			const GLubyte colors[] = {
				color.R, color.G, color.B, color.A,
				color.R, color.G, color.B, color.A
			};
			
			const GLfloat vertices[] = { 
				line.start.X, line.start.Y, line.start.Z, 
				line.end.X, line.end.Y, line.end.Z
			}; 
			
			glVertexPointer(3, GL_FLOAT, 0, vertices);
			glEnableClientState(GL_VERTEX_ARRAY);
			glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
			glEnableClientState(GL_COLOR_ARRAY);
			glDrawArrays(GL_LINE_LOOP, 0, 2);
		}
				
		
	}
	
}



#endif